﻿<%@ WebHandler Language="C#" Class="ListGroupProduct" %>

using System;
using System.Web;
using System.Web.SessionState;
using System.Collections.Generic;

using FiveSister.BAL;

public class ListGroupProduct : AdminHandler
{

    public override void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        if (IsAuthenticate(context))
        {
            try
            {
                int pageIndex = 1, pageMax = 1000, groupProduct = 0, groupParent = 0, isActive = -1;
                if (context.Request.QueryString["pi"] != null)
                    pageIndex = int.Parse(context.Request.QueryString["pi"].ToString());
                if (context.Request.QueryString["pm"] != null)
                    pageMax = int.Parse(context.Request.QueryString["pm"].ToString());
                if (context.Request.QueryString["gi"] != null)
                    groupProduct = int.Parse(context.Request.QueryString["gi"].ToString());

                ///Lỗi procedure
                if (pageIndex == 0)
                    pageIndex = 1;

                string result = "";
                GroupProduct obj = new GroupProduct();
                IList<GroupProduct> list = obj.List(pageIndex, pageMax, groupProduct, groupParent, isActive);
                result = obj.ToJsonList<GroupProduct>(list);
                context.Response.Write(result);
            }
            catch (Exception ex)
            {
                PMSA.Framework.Log.CLogManager.Write("ListBrand.ashx", ex.ToString(), "ADMIN");
                context.Response.Write("FAIL");
            }
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}